// 两个方法：createRouter创建router实例的 ， createWebHashHistory创建hash模式的路由
import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '@/views/Home/index.vue'
import Layout from '@/views/Layout/layout'
import PlayGround from '@/views/Playground'
import CateGory from '@/views/Category'
import CateGorySub from '@/views/Category/Sub'
import Goods from '@/views/Goods'
import Login from '@/views/Login'
import CallBack from '@/views/Login/callback'
import Cart from '@/views/Cart'
// import Message from ''
// routes 路由表
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '/', component: Home },
      { path: '/category/:id', component: CateGory },
      { path: '/category/Sub/:id', component: CateGorySub },
      { path: '/goods/:id', component: Goods },
      { path: '/cart', component: Cart }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/login/callback',
    component: CallBack
  },
  {
    path: '/play',
    component: PlayGround
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')// 懒加载
  }
]
// router就是一个路由实例对象
const router = createRouter({
  // 代表当前路由模式是hash模式
  history: createWebHashHistory(),
  routes
})

export default router
